import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import setupGlobalRouter from './GlobalRouter';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Question',
    component: () => import("../views/question/QuestionView.vue"),
    meta:{  requireAuth: true,roles:['学生','老师','管理员']}
  },
  {
    path: '/about',
    name: 'about',
    component: () => import( '../views/AboutView.vue'),
    meta: { requiresAuth: false }
  },
  {
    path: '/login',
    name: 'login',
    component: () =>import("../views/user/UserLoginView.vue"),
    meta: { requiresAuth: false }
  },
  {
    path:'/question',
    name:'question',
    component:()=>import("../views/question/QuestionView.vue"),
  meta: { requiresAuth: true, roles: ['学生', '老师', '管理员'] }
  },
  {
    path:'/know',
    name:'knowledge',
    component:()=>import("../views/know/KnowledgeBaseManagement.vue"),
    meta: { requiresAuth: true, roles: ['老师', '管理员'] }
  },
  {
    path:'/chat',
    name:'chat',
    component:()=>import("../views/question/ChatView.vue"),
    meta: { requiresAuth: true, roles: ['学生', '老师', '管理员'] }
  },
  {
    path:'/user',
    name:'user',
    component:()=>import("../views/user/UserMegenment.vue"),
    meta: { requiresAuth: true, roles: ['老师','管理员'] }
  },

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})


setupGlobalRouter(router);

export default router
